﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GDI简单介绍
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //绘制这条直线得人
            //纸
            //笔
            //两点确定一条直线
            Graphics g = this.CreateGraphics();
            Pen pen = new Pen(Color.Black);
            Point p1 = new Point(50, 50);
            Point p2 = new Point(100, 100);
            g.DrawLine(pen, p1, p2);

        }
        int i = 0;
        private void button1_Paint(object sender, PaintEventArgs e)
        {
            i++;
            label1.Text = i.ToString(); 
            //paint事件执行
            //当窗体隐藏在出现，绘制的线不会消失
            Graphics g = this.CreateGraphics();
            Pen pen = new Pen(Color.Black);
            Point p1 = new Point(70, 80);
            Point p2 = new Point(200, 210);
            g.DrawLine(pen, p1, p2);
        }
    }
}
